﻿
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using System;
using System.Collections.Generic;

namespace HBase {
    public class MessageDto :MongoPageDto {
        public DateTime? begin;
        public DateTime? end;
        public String info;
        public int sysId;
        public String tableName;


        public override List<IMongoQuery> getRestrict() {
            List<IMongoQuery> queryList = new List<IMongoQuery>();


            if( !String.IsNullOrEmpty(info) ) {
                queryList.Add(Query.Matches("keyCode" ,"/" + info + "/"));
            }
            if( begin != null ) {
                DateTime dt = ( DateTime ) begin;
                queryList.Add(Query.GTE("time" ,dt.Ticks));
            }
            if( end != null ) {
                DateTime dt = ( DateTime ) end;
                queryList.Add(Query.LTE("time" ,dt.Ticks));
            }
            return queryList;
        }

        public override SortByBuilder getOrder() {
            SortByBuilder b = new SortByBuilder();
            b.Descending("status" ,"_id");
            return b;
        }
    }
}
